﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Domain.Service.Order;
using Domain.Entities;
using System.Transactions;

namespace Infrastructure.Order
{
    public class OrderRepository : BackgroundRepository<Order_Info>, IOrderRepository
    {
        public OrderRepository(Domain.Core.IUnitOfWork iUnitWork)
            : base(iUnitWork)
        { }
        public OrderRepository()
        {

        }
        #region IOrderRepository 成员

        public void InsertOrder(Domain.Entities.Order_Info entity)
        {
            using (TransactionScope trans = new TransactionScope())
            {
                try
                {
                    base.Add(entity);
                    trans.Complete();
                }
                catch (Exception)
                {

                    throw;
                }
            }
        }

        public void InsertOrder(List<Domain.Entities.Order_Info> entity)
        {
            entity.ForEach(i =>
            {
                this.InsertOrder(i);
            });
        }
        #endregion
    }
}
